{% extends "base.html" %}
{% block title %}Статистика{% if profile %} :: {{ profile }}{% endif %}{% endblock %}
{% block content %}
{% load filters %} 
{% if user.is_staff and profile %}
<p>Показан трафик только {{ profile }}, <a href="{% url stats %}">показать весь?</a></p>
{% endif %}
{% if categories %}
<p class="traffic_categories">{% for cat in categories %}
<a {% ifequal cat.id category_id %} class="selected" {% endifequal %}" href="{% stats_url profile cat.id year month day %}">{{ cat }}</a>
{% endfor %}
<a {% if not category_id %} class="selected" {% endif %}" href="{% stats_url profile 0 year month day %}">Всё</a>
</p>
<h1 class="traffic_path">{% traffic_path profile category_id year month day %}</h1>
<table id="traffic" class="listing">
  <thead>
    <tr>
      <th>
         {% depth_title depth %}
      </th>
      <th>
         Входящий
      </th>
      <th>
         Исходящий
      </th>
      <th>
         Всего
      </th>
      <th>
         Снято со счёта
      </th>
    </tr>
  </thead>
  <tbody>
     {% for unit in results %}
    <tr class="{% cycle 'odd' 'even' %}">
      <td class="traffic_depth_unit">
         <a href="{% stats_url profile category_id year month day depth unit.0 %}">{{ unit.0|depth_unit:depth }}</a>
      </td>
      <td class="incoming">
         {{ unit.1|human_bytes }}
      </td>
      <td class="outgoing">
         {{ unit.2|human_bytes }}
      </td>
      <td class="total">
          <span style="width: {% widthratio unit.3 max_total 90 %}%">{{ unit.3|human_bytes }}</span>
      </td>
      <td class="cost">
         {{ unit.4|color_balance }} 
      </td>
    </tr>
     {% endfor %} 
  </tbody>
</table>

{% else %}
<p>Ещё нет статистики.</p>
{% endif %}
{% endblock %}
